import 'dart:async';

import 'package:flutter/material.dart';
import 'package:shopping_group/res/colors.dart';
import 'package:shopping_group/res/dimens.dart';

import 'widget_utils.dart';

class ShowToast {
//  static showToastLong(String event) {
//    Fluttertoast.showToast(
//        msg: event,
//        toastLength: Toast.LENGTH_SHORT,
//        gravity: ToastGravity.CENTER,
//        timeInSecForIos: 1);
//  }

//  static showToastCertenLong(String event) {
//    Fluttertoast.showToast(
//        msg: event,
//        toastLength: Toast.LENGTH_SHORT,
//        gravity: ToastGravity.CENTER,
//        timeInSecForIos: 1);
//  }
  static void showToast(BuildContext context, String text) {
    Widget widget = Center(
      child: Container(
        decoration: BoxDecoration(
            color: Colours.text_2222.withOpacity(0.5),
            border: Border.all(
                color: Colours.text_2222.withOpacity(0.5), width: 1.0),
            borderRadius: BorderRadius.circular(30.0)),
        // color: Colours.text_2222.withOpacity(0.5),
        padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
        child: WidgetUtils.getTextColorView(
            text, Colors.white, Dimens.FONT_SIZE_16),
      ),
    );
    var entry = OverlayEntry(
      builder: (_) => widget,
    );

    Overlay.of(context).insert(entry);

    Timer(const Duration(seconds: 2), () {
      entry?.remove();
    });
  }
}
